def s(x):
    if x == 1: return False
    t = True
    k = x - 1
    while k > 1:
        if not x % k:
            t = False
            break
        k -= 1
    return t
n = input()
x = 0
d = len(n)
for i in range(d):
    for j in reversed(range(i + 1, d + 1)):
        x = int(n[i:j])
        if s(x): break
        x = 0
    if x > 0: break
print(x)
